package com.mugcode.hosp.controller;

import com.mugcode.common.result.Result;
import com.mugcode.entity.model.hosp.Hospital;
import com.mugcode.entity.vo.hosp.HospitalQueryVo;
import com.mugcode.hosp.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * projectName: appointment
 * <p>
 * author: Mu
 * time: 2023/5/29 10:13
 * description:
 */
@Api(tags="医院列表")
@RestController
@RequestMapping("/admin/hosp/hospital")
@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    //医院列表(条件查询)
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page, @PathVariable Integer limit, HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        List<Hospital> content = pageModel.getContent();
        long totalElements = pageModel.getTotalElements();
        return Result.ok(pageModel);
    }

    @ApiOperation(value="更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result lock(@ApiParam(name="id", value="医院id",required=true)
                       @PathVariable("id") String id,
                       @ApiParam(name="status", value="状态(0:未上线 1:已上线)",required = true)
                       @PathVariable("status") Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

}
